<!DOCTYPE html>
<html>
<head>
    <title>CareNote-ModuleUpdate</title>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no"/>

    <link href="../../../static/css/normalize.css" type="text/css" rel="stylesheet"/>
    <link href="../../../static/css/common.css" type="text/css" rel="stylesheet"/>
    <script src="../../../static/js/jquery.min.js" type="text/javascript"></script>
    <script src="../../../static/js/common.js" type="text/javascript"></script>
    <script src="../../../static/js/notice.js" type="text/javascript"></script>
    <script src="../../../static/js/regexp.js" type="text/javascript"></script>
    <script src="../../../static/js/jweixin-1.2.0.js" type="text/javascript"></script>
    <style type="text/css">
        .content {
            position: relative;
        }

        .expEnterCont {
            padding-bottom: 20px;
        }

        .expEnterCont .expEnterIcon {
            width: 20%;
            margin: 0 auto;
        }

        .expEnterCont .expEnterIcon p {
            text-align: center;
            font-weight: bold;
        }

        .submitBtn {
            width: 90%;
            margin: 0 auto;
            text-align: center;
            line-height: 46px;
            border-radius: 23px;
            background: #1f72ff;
            color: #fff;
            font-weight: bolder;
        }

        .stopvoicerecord {
            width: 40%;
            height: 50px;
            position: absolute;
            top: 20px;
            right: 40px;
            display: none;
            background: purple;
        }

        .stopvoicerecord {
            position: absolute;
            top: 0%;
            left: 0%;
            width: 100%;
            height: 100%;
            background-color: rgba(0, 0, 0, 0.5);
            z-index: 1001;
            display: none;
        }

        .stopvoicerecord .voiceRecordCont {
            width: 60%;
            background: #fff;
            border-radius: 8px;
            position: absolute;
            top: calc((100% - 216px) / 2); /*30 + 110 +30 + 10 +36 == 216*/
            left: 20%;
            padding: 20px 0px 10px;
        }

        .stopvoicerecord .voiceRecordCont img {
            display: block;
            margin: 0 auto;
            width: 110px;
        }

        .stopvoicerecord .voiceRecordCont .voiceRecordState {
            margin: 0px;
            text-align: center;
            font-size: 14px;
            color: #777777;
            line-height: 30px;
        }

        .stopvoicerecord .voiceRecordCont #stopVoiceRecordBtn {
            margin: 10px auto 0;
            width: 90%;
            text-align: center;
            line-height: 36px;
            background: #3eb94e;
            font-size: 14px;
            color: #fff;
            font-weight: bold;
            border-radius: 18px;
        }
    </style>
</head>
<body>
<div class="content">
    <div class="headerNav">
        <div class="headerNavTop">
            <div class="headerNavIcon headerNavIconOut"><span></span><span></span></div>
        </div>
        <div class="headerNavCont">
            <a href="/user/console">用户首页</a>
            <a href="/user/my">个人中心</a>
            <a href="/user/module">模板信息</a>
            <a href="/user/setting">关怀信息</a>
            <a href="/jimo.fun">JIMO友情🔗</a>
        </div>
    </div>

    <div class="expEnterCont">
        <div class="expEnterIcon">
            <img src="../../../static/img/img.png" width="128" alt="">
            <p id="title">创建、修改模板</p>
        </div>
        <div class="expEnterInput">
            <input id="timestamp" type="hidden" value="${timestamp}"/>
            <input id="noncestr" type="hidden" value="${nonceStr}"/>
            <input id="signature" type="hidden" value="${signature}"/>
            <input id="appId" type="hidden" value="${appId}"/>
            <form>
                <input id="PageContext" type="hidden" value="${pageContext.request.contextPath}"/>
                <input id="wxCode" type="hidden" value="${wxCode}"/>
                <div class="userInputCont">
                    <div class="inputTypeCont">
                        <div class="inputTitle">名字</div>
                        <label for="v1"></label><input type="text" id="v1" class="commonInputFunc"
                                                       name="expressId" placeholder="请输入模板名字，不可为空且不可重复！！！">
                    </div>
                    <div class="inputTypeCont">
                        <div class="inputTitle">天气</div>
                        <label for="v2"></label><input type="text" id="v2" class="commonInputFunc"
                                                       name="phone" placeholder="请输入天气信息，空为自动">
                    </div>
                    <div class="inputTypeCont">
                        <div class="inputTitle">温度</div>
                        <label for="v3"></label><input type="text" id="v3" class="commonInputFunc" name="phone"
                                                       placeholder="温度信息，空为自动">
                    </div>
                    <div class="inputTypeCont">
                        <div class="inputTitle">早安</div>
                        <label for="v4"></label><input type="text" id="v4" class="commonInputFunc" name="phone"
                                                       placeholder="早安信息，空为自动">
                    </div>
                    <div class="inputTypeCont">
                        <div class="inputTitle">午安</div>
                        <label for="v5"></label><input type="text" id="v5" class="commonInputFunc" name="phone"
                                                       placeholder="午安信息，空为自动">
                    </div>
                    <div class="inputTypeCont">
                        <div class="inputTitle">晚安</div>
                        <label for="v6"></label><input type="text" id="v6" class="commonInputFunc" name="phone"
                                                       placeholder="晚安信息，空为自动">
                    </div>
                    <div class="inputTypeCont">
                        <div class="inputTitle">公开</div>
                        <label for="v7"></label>
                        <select id="v7" name="company">
                            <option id="uID">私人模板</option>
                            <option value="0">公开模板（中性）</option>
                            <option value="-2">公开模板（女）</option>
                            <option value="-1">公开模板（男）</option>
                        </select>
                    </div>
                </div>
            </form>
            <div class="submitBtn" type="button">上传模板信息</div>
        </div>
    </div>
</div>
<script src="../../../static/layer/layer.js"></script>
<script type="text/javascript">
    $(function () {
        /*判断信息进行初始化处理*/
        $.post("/user/module/get", null, function (message) {
            if (message.status ===200||message.status===201) {
                $("#title").html(message.result);
                layer.msg(message.result);
                if (message.status === 200) {
                    $("#uID").val(message.data);
                    return;
                }
                if (message.data !== null) {
                    $("#uID").val(message.data.uId);
                    $("#v1").val(message.data.name);
                    $("#v2").val(message.data.status);
                    $("#v3").val(message.data.temp);
                    $("#v4").val(message.data.morning);
                    $("#v5").val(message.data.noon);
                    $("#v6").val(message.data.evening);
                }
            }
        });
        /*添加或修改的业务处理*/
        $(".submitBtn").click(function () {
            let val = $.trim($("#v1").val());
            let val1 = $.trim($("#v2").val());
            let val2 = $.trim($("#v3").val());
            let val3 = $.trim($("#v4").val());
            let val4 = $.trim($("#v5").val());
            let val5 = $.trim($("#v6").val());
            let val6 = $.trim($("#v7").val());
            if (val === "" || val.length === 0||val.length>15) {
                layer.msg("名字坚决不能为空，且不可超过十五字啊！")
                return;
            }
            if(val1.length>34||val2.length>34||val3.length>34||val4>34||val5>34){
                layer.msg("模板信息可为空，但是不可超过34字啊！")
                return;
            }
            let load = layer.load();
            $.post("/user/mondule/post", {
                name: val,
                status: val1,
                temp: val2,
                morning: val3,
                noon: val4,
                evening: val5,
                uId: val6
            }, function (data) {
                layer.close(load);
                layer.msg(data.result);
                if (data.status === 200) {
                    //录入成功
                    window.location.href = "/user/module";
                } else {
                    //录入失败
                }
            });
        });
    });

</script>
</body>
</html>